package com.ijiuchuang.jc_localization.presenter;

import android.content.Context;

import com.ijiuchuang.jc_localization.bean.lite.Tag;
import com.ijiuchuang.jc_localization.contract.DeviceListContract;
import com.ijiuchuang.jc_localization.contract.LocationContract;
import com.ijiuchuang.jc_localization.model.DeviceListModel;

import java.util.List;

import rx.functions.Action1;

/**
 * Created by Veev on 2016/6/14
 *
 * @link 384506557@qq.com
 */
public class DeviceListPresenter implements DeviceListContract.Presenter {

    private Context mContext;
    private DeviceListContract.View mDeviceListView;
    private DeviceListContract.Model mDeviceListModel;
    private LocationContract.Model mMainModel;

    public DeviceListPresenter(Context mContext, DeviceListContract.View mDeviceListView) {
        this.mContext = mContext;
        this.mDeviceListView = mDeviceListView;
        mDeviceListModel = new DeviceListModel();

        mDeviceListView.setPresenter(this);
    }

    @Override
    public void start() {
        // start here
        setDatas();
    }

    @Override
    public void setDatas() {
        mDeviceListModel.getDatas(new Action1<List<Tag>>() {
            @Override
            public void call(List<Tag> tags) {
                mDeviceListView.setDatas(tags);
            }
        });
    }

    @Override
    public void deleteData(Object tag) {
        mDeviceListModel.deleteData(tag);
    }

    @Override
    public void changeName(Tag tag, String name) {
        mDeviceListModel.changeName(tag, name);
    }
}